package reese.springmvc.mvc_01_handlerMapping;

import org.springframework.web.servlet.HandlerExecutionChain;
import org.springframework.web.servlet.HandlerMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * ***********************************************************
 *
 * @类名 : reese.springmvc.mvc_01_handlerMapping.类名
 * @DESCRIPTION : 模拟handlerMapping,但是需要注册到springmvc容器中才能生效
 * @AUTHOR :  一个风情万种的男子
 * @DATE : 2016/4/27
 * ***********************************************************
 */
public class DiguaHandlerMapping implements HandlerMapping {
    public HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception {

        String url = request.getRequestURI().toString();
        String method = request.getMethod();

        if(url.startsWith("/tudou")){
            //转发
            //判断是get或者是Post
            if(method.equalsIgnoreCase("GET")){
                //return handler1

            }else if(method.equalsIgnoreCase("POST")){
                //return handler2
            }else {
                System.out.println("DiguaHandlerMapping其他对应的handler");
            }
        }
        return null;
    }
}
